<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"/>
    <title>{:L('登录')}</title>
    <include file="Public:head"/>
</head>
<body style="background-color:#313e51;">
<header class="mui-bar mui-bar-bg mui-bar-nav">
    <a class="mui-icon mui-icon-left-nav mui-pull-left" href="{:U('Trade/tradelist')}"></a>
    <h1 class="mui-title color_white"></h1>
</header>
<div class="mui-content cur-padding-bottom" style="background:inherit;">
    <div class="mylogin">
        <p class="title"><b>{:L('登录')}</b></p>

        <div class="login-input-group">
            <div class="mui-input-row">
                <input type="text" name="username" id="login_username" class="mui-input-clear" autocomplete="off">
                <label class="input--label--akira">{:L('手机号码')}</label>
            </div>
            <div class="mui-input-row">
                <input type="password" name="password" id="login_password" class="mui-input-clear mui-input-password"
                       autocomplete="off">
                <label class="input--label--akira">{:L('登录密码')}</label>
            </div>
            <div class="mui-input-row">
                <div class="btn-right">
                    <img height="37" src="{:U('Verify/code')}" onclick="this.src=this.src+'?t='+Math.random()"
                         title="{:L('换一张')}" id="verifycode">
                </div>
                <input type="text" name="code" id="login_verify" class="mui-input-clear" autocomplete="off">
                <label class="input--label--akira">{:L('图形验证码')}</label>
            </div>
            <div class="mui-input-row">
                <input type="text" id="foot_ga" class="mui-input-clear" autocomplete="off">
                <label class="input--label--akira">{:L('谷歌验证码（未绑定无需填写）')}</label>
            </div>

            <div class="mui-button-row" style="margin-top:25px;">
                <button type="button" class="mui-btn mui-btn-primary" onclick="upLogin();">登录</button>
            </div>
        </div>
        <p class="text-s" style="margin-top:25px;font-size:14px;"><a href="{:U('Login/findpwd')}">{:L('忘记密码')}?</a></p>
        <p class="text-s tc" style="margin-top:60px;">还没有账号？<a href="{:U('Login/register')}" style="margin-left:10px;">注册</a>
        </p>
    </div>
</div>

<script src="__PUBLIC__/Mobile/ecshe_js/mui.min.js"></script>
<script type="text/javascript">
    mui.init();
</script>
<script src="__PUBLIC__/Mobile/ecshe_js/classie.js"></script>
<script type="text/javascript">
    (function () {
        if (!String.prototype.trim) {
            (function () {
                // Make sure we trim BOM and NBSP
                var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
                String.prototype.trim = function () {
                    return this.replace(rtrim, '');
                };
            })();
        }

        [].slice.call(document.querySelectorAll('input.mui-input-clear')).forEach(function (inputEl) {
            // in case the input is already filled..
            if (inputEl.value.trim() !== '') {
                classie.add(inputEl.parentNode, 'input--filled');
            }
            // events:
            inputEl.addEventListener('focus', onInputFocus);
            inputEl.addEventListener('blur', onInputBlur);
        });

        function onInputFocus(ev) {
            classie.add(ev.target.parentNode, 'input--filled');
        }

        function onInputBlur(ev) {
            if (ev.target.value.trim() === '') {
                classie.remove(ev.target.parentNode, 'input--filled');
            }
        }
    })();
</script>

<script type="text/javascript">
    function upLogin() {
        var username = $("#login_username").val();
        var password = $("#login_password").val();
        var verify = $("#login_verify").val();
        var foot_ga = $("#foot_ga").val();

        if (username == "" || username == null) {
            layer.tips('{:L('
            请输入手机号
            ')}', '#login_username', {tips: 3}
        )
            ;
            return false;
        }
        if (password == "" || password == null) {
            layer.tips('{:L('
            请输入登录密码
            ')}', '#login_password', {tips: 3}
        )
            ;
            return false;
        }
        if (verify == "" || verify == null) {
            layer.tips('{:L('
            请输入验证码
            ')}', '#login_verify', {tips: 3}
        )
            ;
            return false;
        }

        $.post("{:U('Login/submit')}", {
            username: username,
            password: password,
            verify: verify,
            ga: foot_ga
        }, function (data) {
            if (data.status == 1) {
                $("#login_verify").val('');
                layer.msg(data.info, {icon: 1});
                window.setTimeout("window.location='/'", 1000);
            } else {
                $("#login_verify").val('');
                layer.msg(data.info, {icon: 2});
                $('#verifycode').click();
                if (data.url) {
                    window.setTimeout("window.location='/'", 1000);
                }
            }
        }, "json");
    }

    $('#menu_top_index').addClass('current');
</script>
<script language="JavaScript">
    function keyLogin() {
        if (event.keyCode == 13) // The key value of the return key is 13
            upLogin();
    }
</script>
</body>
</html>